import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
fig = plt.figure(1)
gs = GridSpec(3,3)
ax1 = plt.subplot(gs[0,0])
ax11 = plt.subplot(gs[0,1])
ax2 = plt.subplot(gs[1,0])
ax3 = plt.subplot(gs[1,1])
ax4 = plt.subplot(gs[1,2])
ax5 = plt.subplot(gs[2,0])
ax6 = plt.subplot(gs[2,1])


# ----------------------------
url = 'https://www.gairuo.com/file/data/dataset/iris.data'
df1 = pd.read_csv(url)

df1['sepal_length'].plot.hist(rwidth=0.9,density=True,ax=ax1)
df1['sepal_length'].plot.kde(ax=ax11)

# ----------------------------
gdf = pd.read_csv(r"C:\Users\HP\Desktop\gdp.csv").set_index('province')
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
four = gdf.iloc[[0,8,9,18]]
four.T.sort_index().plot.line(ax=ax2)
four['2016y'].plot.bar(rot=0,ax=ax3)
four.T.sum().plot.pie(ax=ax4)

# ================================
df3 = pd.read_csv(r"C:\Users\HP\Desktop\crime.csv").loc[1:]

df3.plot.scatter(x = 'forcible_rape', y = 'murder', s=df3['population']//300000,ax=ax5)
df3.plot.scatter(x = 'forcible_rape', y = 'burglary', s=df3['population']//300000 ,ax=ax6)

plt.show()

# 2----------------------------
gdf = pd.read_csv(r"C:\Users\HP\Desktop\gdp.csv").set_index('province')
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
four = gdf.iloc[[0,8,9,18]]
four.T.sort_index().plot.line(ax=ax2)
four['2016y'].plot.bar(rot=0,ax=ax3)
four.T.sum().plot.pie(ax=ax4)
# 3================================
df3 = pd.read_csv(r"C:\Users\HP\Desktop\crime.csv").loc[1:]

df3.plot.scatter(x = 'forcible_rape', y = 'murder', s=df3['population']//300000,ax=ax5)
df3.plot.scatter(x = 'forcible_rape', y = 'burglary', s=df3['population']//300000 ,ax=ax6)

plt.show()
# from matplotlib.gridspec import GridSpec
# fig = plt.figure(1)
# gs = GridSpec(3,3)
# ax1 = plt.subplot(gs[0,0])
# ax2 = plt.subplot(gs[0,1])
# ax3 = plt.subplot(gs[1,:])